<?php



//-----------------------------------------------------------
//config文件请勿修改，因修改此文件造成无法解析概不负责！
//-----------------------------------------------------------


//错误提示
error_reporting(0);
//默认时区
date_default_timezone_set("Asia/Shanghai");
//加载文件
require_once FCPATH . 'user.php';
//设置路径
define('URL_ML', $user['path']);
//用户授权UID
define('USER_UID', $user['uid']);
//用户授权TOKEN
define('USER_TOKEN', $user['token']);
//用户设置解析名称
define('USER_TITLE', $user['title']);
//
define('USER_DPLAYE', $user['dplaye']);
//用户设置的清晰度
define('VOD_HD', $user['hdd']);
//用户设置PC播放模式
define('USER_AUTO', $user['autoplay']);
//用户设置H5播放模式
define('USER_AUTO_H5', $user['h5']);
//用户设置防盗跳转时间
define('USER_LOTIME', $user['lotime']);
//用户设置页面统计
define('USER_TONGJI', $user['tongji']);
//用户设置防盗跳转
define('USER_LOLINK', $user['lolink']);
//用户设置广告
define('USER_AD', $user['ad']);
//判断手机客户端
$wap = preg_match("/(iPhone|iPad|iPod|Linux|Android)/i", strtoupper($_SERVER['HTTP_USER_AGENT']));
//当前环境
define('HOST', base64_encode($_SERVER['HTTP_HOST']));

function is_referer(){
	//没有设置防盗链
    if(REFERER_URL=='') return true; 
	//获取来路域名
	$uriarr = parse_url($_SERVER['HTTP_REFERER']);
	$host = $uriarr['host'];
	$ymarr = explode("|",REFERER_URL);
    if(in_array($host,$ymarr)){
    	return true;
    }
    return false;
}
function unlock_url($txt,$key='www.xfylhl.com')
{
  $txt = base64_decode(urldecode($txt));
  $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+";
  $ch = $txt[0];
  $nh = strpos($chars,$ch);
  $mdKey = md5($key.$ch);
  $mdKey = substr($mdKey,$nh%8, $nh%8+7);
  $txt = substr($txt,1);
  $tmp = '';
  $i=0;$j=0; $k = 0;
  for ($i=0; $i<strlen($txt); $i++) {
    $k = $k == strlen($mdKey) ? 0 : $k;
    $j = strpos($chars,$txt[$i])-$nh - ord($mdKey[$k++]);
    while ($j<0) $j+=64;
    $tmp .= $chars[$j];
  }
  return trim(base64_decode($tmp),$key);
}

function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {   
    $ckey_length = 4;   
    $key = md5($key ? $key : $GLOBALS['discuz_auth_key']);   
       
    $keya = md5(substr($key, 0, 16));
    $keyb = md5(substr($key, 16, 16));   
    $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): 
substr(md5(microtime()), -$ckey_length)) : '';   
    $cryptkey = $keya.md5($keya.$keyc);   
    $key_length = strlen($cryptkey);   
    $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) :  
sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;   
    $string_length = strlen($string);   
    $result = '';   
    $box = range(0, 255);   
    $rndkey = array();   
    for($i = 0; $i <= 255; $i++) {   
        $rndkey[$i] = ord($cryptkey[$i % $key_length]);   
    }   
    for($j = $i = 0; $i < 256; $i++) {   
        $j = ($j + $box[$i] + $rndkey[$i]) % 256;   
        $tmp = $box[$i];   
        $box[$i] = $box[$j];   
        $box[$j] = $tmp;   
    }   
    for($a = $j = $i = 0; $i < $string_length; $i++) {   
        $a = ($a + 1) % 256;   
        $j = ($j + $box[$a]) % 256;   
        $tmp = $box[$a];   
        $box[$a] = $box[$j];   
        $box[$j] = $tmp;   
        $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));   
    }   
    if($operation == 'DECODE') {  
        if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) &&  
substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {   
            return substr($result, 26);   
        } else {   
            return '';   
        }   
    } else {   
        return $keyc.str_replace('=', '', base64_encode($result));   
    }   
} 

function get_real_ip(){
  static $realip;
  if(isset($_SERVER)){
    if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
      $realip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }else if(isset($_SERVER['HTTP_CLIENT_IP'])){
      $realip=$_SERVER['HTTP_CLIENT_IP'];
    }else{
      $realip=$_SERVER['REMOTE_ADDR'];
    }
  }else{
    if(getenv('HTTP_X_FORWARDED_FOR')){
      $realip=getenv('HTTP_X_FORWARDED_FOR');
    }else if(getenv('HTTP_CLIENT_IP')){
      $realip=getenv('HTTP_CLIENT_IP');
    }else{
      $realip=getenv('REMOTE_ADDR');
    }
  }
  return $realip;
}
$keya = "https://www.xfylhl.com/";
function check_wap(){
  // 先检查是否为wap代理，准确度高
  if(stristr($_SERVER['HTTP_VIA'],"wap")){
    return true;
  }
  // 检查浏览器是否接受 WML.
  else if(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML") > 0)
  {
    return true;
  }
  //检查USER_AGENT
  else if(preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])){
    return true;       
  }
  else{
    return false;  
  }

}
$api_ckflv = unlock_url($keya);
function getRandomString($len, $chars=null)
{
    if (is_null($chars)){
        $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    }  
    mt_srand(10000000*(double)microtime());
    for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++){
        $str .= $chars[mt_rand(0, $lc)];  
    }
    return $str;
}
$vapi = nl2br(file_get_contents("https://jx.xfylhl.com/gh/ad.txt"));
